/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.Activity;
import bpmn.ActivityType;
import bpmn.BpmnPackage;
import bpmn.Expression;
import bpmn.InputSet;
import bpmn.LoopType;
import bpmn.OutputSet;
import bpmn.Property;
import bpmn.StatusType;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Activity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.ActivityImpl#getActivityType <em>Activity Type</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getStatus <em>Status</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getPerformers <em>Performers</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getProperties <em>Properties</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getInputSets <em>Input Sets</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getOutputSets <em>Output Sets</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getIORules <em>IO Rules</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getStartQuantity <em>Start Quantity</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getCompletionQuantity <em>Completion Quantity</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getLoopType <em>Loop Type</em>}</li>
 *   <li>{@link bpmn.impl.ActivityImpl#getIsForCompensation <em>Is For Compensation</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class ActivityImpl extends FlowObjectImpl implements Activity {
	/**
	 * The default value of the '{@link #getActivityType() <em>Activity Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getActivityType()
	 * @generated
	 * @ordered
	 */
	protected static final ActivityType ACTIVITY_TYPE_EDEFAULT = ActivityType.TASK;

	/**
	 * The cached value of the '{@link #getActivityType() <em>Activity Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getActivityType()
	 * @generated
	 * @ordered
	 */
	protected ActivityType activityType = ACTIVITY_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getStatus() <em>Status</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStatus()
	 * @generated
	 * @ordered
	 */
	protected static final StatusType STATUS_EDEFAULT = StatusType.NONE;

	/**
	 * The cached value of the '{@link #getStatus() <em>Status</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStatus()
	 * @generated
	 * @ordered
	 */
	protected StatusType status = STATUS_EDEFAULT;

	/**
	 * The cached value of the '{@link #getPerformers() <em>Performers</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPerformers()
	 * @generated
	 * @ordered
	 */
	protected EList<String> performers;

	/**
	 * The cached value of the '{@link #getProperties() <em>Properties</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProperties()
	 * @generated
	 * @ordered
	 */
	protected EList<Property> properties;

	/**
	 * The cached value of the '{@link #getInputSets() <em>Input Sets</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInputSets()
	 * @generated
	 * @ordered
	 */
	protected EList<InputSet> inputSets;

	/**
	 * The cached value of the '{@link #getOutputSets() <em>Output Sets</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutputSets()
	 * @generated
	 * @ordered
	 */
	protected EList<OutputSet> outputSets;

	/**
	 * The cached value of the '{@link #getIORules() <em>IO Rules</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIORules()
	 * @generated
	 * @ordered
	 */
	protected EList<Expression> ioRules;

	/**
	 * The default value of the '{@link #getStartQuantity() <em>Start Quantity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStartQuantity()
	 * @generated
	 * @ordered
	 */
	protected static final short START_QUANTITY_EDEFAULT = 1;

	/**
	 * The cached value of the '{@link #getStartQuantity() <em>Start Quantity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStartQuantity()
	 * @generated
	 * @ordered
	 */
	protected short startQuantity = START_QUANTITY_EDEFAULT;

	/**
	 * The default value of the '{@link #getCompletionQuantity() <em>Completion Quantity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCompletionQuantity()
	 * @generated
	 * @ordered
	 */
	protected static final short COMPLETION_QUANTITY_EDEFAULT = 1;

	/**
	 * The cached value of the '{@link #getCompletionQuantity() <em>Completion Quantity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCompletionQuantity()
	 * @generated
	 * @ordered
	 */
	protected short completionQuantity = COMPLETION_QUANTITY_EDEFAULT;

	/**
	 * The default value of the '{@link #getLoopType() <em>Loop Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopType()
	 * @generated
	 * @ordered
	 */
	protected static final LoopType LOOP_TYPE_EDEFAULT = LoopType.NONE;

	/**
	 * The cached value of the '{@link #getLoopType() <em>Loop Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopType()
	 * @generated
	 * @ordered
	 */
	protected LoopType loopType = LOOP_TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #getIsForCompensation() <em>Is For Compensation</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIsForCompensation()
	 * @generated
	 * @ordered
	 */
	protected static final Boolean IS_FOR_COMPENSATION_EDEFAULT = Boolean.FALSE;

	/**
	 * The cached value of the '{@link #getIsForCompensation() <em>Is For Compensation</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIsForCompensation()
	 * @generated
	 * @ordered
	 */
	protected Boolean isForCompensation = IS_FOR_COMPENSATION_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActivityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.ACTIVITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActivityType getActivityType() {
		return activityType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setActivityType(ActivityType newActivityType) {
		ActivityType oldActivityType = activityType;
		activityType = newActivityType == null ? ACTIVITY_TYPE_EDEFAULT : newActivityType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ACTIVITY__ACTIVITY_TYPE, oldActivityType, activityType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public StatusType getStatus() {
		return status;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStatus(StatusType newStatus) {
		StatusType oldStatus = status;
		status = newStatus == null ? STATUS_EDEFAULT : newStatus;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ACTIVITY__STATUS, oldStatus, status));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<String> getPerformers() {
		if (performers == null) {
			performers = new EDataTypeUniqueEList<String>(String.class, this, BpmnPackage.ACTIVITY__PERFORMERS);
		}
		return performers;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Property> getProperties() {
		if (properties == null) {
			properties = new EObjectContainmentEList<Property>(Property.class, this, BpmnPackage.ACTIVITY__PROPERTIES);
		}
		return properties;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<InputSet> getInputSets() {
		if (inputSets == null) {
			inputSets = new EObjectResolvingEList<InputSet>(InputSet.class, this, BpmnPackage.ACTIVITY__INPUT_SETS);
		}
		return inputSets;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<OutputSet> getOutputSets() {
		if (outputSets == null) {
			outputSets = new EObjectResolvingEList<OutputSet>(OutputSet.class, this, BpmnPackage.ACTIVITY__OUTPUT_SETS);
		}
		return outputSets;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Expression> getIORules() {
		if (ioRules == null) {
			ioRules = new EObjectResolvingEList<Expression>(Expression.class, this, BpmnPackage.ACTIVITY__IO_RULES);
		}
		return ioRules;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getStartQuantity() {
		return startQuantity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStartQuantity(short newStartQuantity) {
		short oldStartQuantity = startQuantity;
		startQuantity = newStartQuantity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ACTIVITY__START_QUANTITY, oldStartQuantity, startQuantity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getCompletionQuantity() {
		return completionQuantity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCompletionQuantity(short newCompletionQuantity) {
		short oldCompletionQuantity = completionQuantity;
		completionQuantity = newCompletionQuantity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ACTIVITY__COMPLETION_QUANTITY, oldCompletionQuantity, completionQuantity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public LoopType getLoopType() {
		return loopType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLoopType(LoopType newLoopType) {
		LoopType oldLoopType = loopType;
		loopType = newLoopType == null ? LOOP_TYPE_EDEFAULT : newLoopType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ACTIVITY__LOOP_TYPE, oldLoopType, loopType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Boolean getIsForCompensation() {
		return isForCompensation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIsForCompensation(Boolean newIsForCompensation) {
		Boolean oldIsForCompensation = isForCompensation;
		isForCompensation = newIsForCompensation;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ACTIVITY__IS_FOR_COMPENSATION, oldIsForCompensation, isForCompensation));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case BpmnPackage.ACTIVITY__PROPERTIES:
				return ((InternalEList<?>)getProperties()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.ACTIVITY__ACTIVITY_TYPE:
				return getActivityType();
			case BpmnPackage.ACTIVITY__STATUS:
				return getStatus();
			case BpmnPackage.ACTIVITY__PERFORMERS:
				return getPerformers();
			case BpmnPackage.ACTIVITY__PROPERTIES:
				return getProperties();
			case BpmnPackage.ACTIVITY__INPUT_SETS:
				return getInputSets();
			case BpmnPackage.ACTIVITY__OUTPUT_SETS:
				return getOutputSets();
			case BpmnPackage.ACTIVITY__IO_RULES:
				return getIORules();
			case BpmnPackage.ACTIVITY__START_QUANTITY:
				return getStartQuantity();
			case BpmnPackage.ACTIVITY__COMPLETION_QUANTITY:
				return getCompletionQuantity();
			case BpmnPackage.ACTIVITY__LOOP_TYPE:
				return getLoopType();
			case BpmnPackage.ACTIVITY__IS_FOR_COMPENSATION:
				return getIsForCompensation();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.ACTIVITY__ACTIVITY_TYPE:
				setActivityType((ActivityType)newValue);
				return;
			case BpmnPackage.ACTIVITY__STATUS:
				setStatus((StatusType)newValue);
				return;
			case BpmnPackage.ACTIVITY__PERFORMERS:
				getPerformers().clear();
				getPerformers().addAll((Collection<? extends String>)newValue);
				return;
			case BpmnPackage.ACTIVITY__PROPERTIES:
				getProperties().clear();
				getProperties().addAll((Collection<? extends Property>)newValue);
				return;
			case BpmnPackage.ACTIVITY__INPUT_SETS:
				getInputSets().clear();
				getInputSets().addAll((Collection<? extends InputSet>)newValue);
				return;
			case BpmnPackage.ACTIVITY__OUTPUT_SETS:
				getOutputSets().clear();
				getOutputSets().addAll((Collection<? extends OutputSet>)newValue);
				return;
			case BpmnPackage.ACTIVITY__IO_RULES:
				getIORules().clear();
				getIORules().addAll((Collection<? extends Expression>)newValue);
				return;
			case BpmnPackage.ACTIVITY__START_QUANTITY:
				setStartQuantity((Short)newValue);
				return;
			case BpmnPackage.ACTIVITY__COMPLETION_QUANTITY:
				setCompletionQuantity((Short)newValue);
				return;
			case BpmnPackage.ACTIVITY__LOOP_TYPE:
				setLoopType((LoopType)newValue);
				return;
			case BpmnPackage.ACTIVITY__IS_FOR_COMPENSATION:
				setIsForCompensation((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.ACTIVITY__ACTIVITY_TYPE:
				setActivityType(ACTIVITY_TYPE_EDEFAULT);
				return;
			case BpmnPackage.ACTIVITY__STATUS:
				setStatus(STATUS_EDEFAULT);
				return;
			case BpmnPackage.ACTIVITY__PERFORMERS:
				getPerformers().clear();
				return;
			case BpmnPackage.ACTIVITY__PROPERTIES:
				getProperties().clear();
				return;
			case BpmnPackage.ACTIVITY__INPUT_SETS:
				getInputSets().clear();
				return;
			case BpmnPackage.ACTIVITY__OUTPUT_SETS:
				getOutputSets().clear();
				return;
			case BpmnPackage.ACTIVITY__IO_RULES:
				getIORules().clear();
				return;
			case BpmnPackage.ACTIVITY__START_QUANTITY:
				setStartQuantity(START_QUANTITY_EDEFAULT);
				return;
			case BpmnPackage.ACTIVITY__COMPLETION_QUANTITY:
				setCompletionQuantity(COMPLETION_QUANTITY_EDEFAULT);
				return;
			case BpmnPackage.ACTIVITY__LOOP_TYPE:
				setLoopType(LOOP_TYPE_EDEFAULT);
				return;
			case BpmnPackage.ACTIVITY__IS_FOR_COMPENSATION:
				setIsForCompensation(IS_FOR_COMPENSATION_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.ACTIVITY__ACTIVITY_TYPE:
				return activityType != ACTIVITY_TYPE_EDEFAULT;
			case BpmnPackage.ACTIVITY__STATUS:
				return status != STATUS_EDEFAULT;
			case BpmnPackage.ACTIVITY__PERFORMERS:
				return performers != null && !performers.isEmpty();
			case BpmnPackage.ACTIVITY__PROPERTIES:
				return properties != null && !properties.isEmpty();
			case BpmnPackage.ACTIVITY__INPUT_SETS:
				return inputSets != null && !inputSets.isEmpty();
			case BpmnPackage.ACTIVITY__OUTPUT_SETS:
				return outputSets != null && !outputSets.isEmpty();
			case BpmnPackage.ACTIVITY__IO_RULES:
				return ioRules != null && !ioRules.isEmpty();
			case BpmnPackage.ACTIVITY__START_QUANTITY:
				return startQuantity != START_QUANTITY_EDEFAULT;
			case BpmnPackage.ACTIVITY__COMPLETION_QUANTITY:
				return completionQuantity != COMPLETION_QUANTITY_EDEFAULT;
			case BpmnPackage.ACTIVITY__LOOP_TYPE:
				return loopType != LOOP_TYPE_EDEFAULT;
			case BpmnPackage.ACTIVITY__IS_FOR_COMPENSATION:
				return IS_FOR_COMPENSATION_EDEFAULT == null ? isForCompensation != null : !IS_FOR_COMPENSATION_EDEFAULT.equals(isForCompensation);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (ActivityType: ");
		result.append(activityType);
		result.append(", Status: ");
		result.append(status);
		result.append(", Performers: ");
		result.append(performers);
		result.append(", StartQuantity: ");
		result.append(startQuantity);
		result.append(", CompletionQuantity: ");
		result.append(completionQuantity);
		result.append(", LoopType: ");
		result.append(loopType);
		result.append(", IsForCompensation: ");
		result.append(isForCompensation);
		result.append(')');
		return result.toString();
	}

} //ActivityImpl
